package com.annotationAndReflection;

public class TestclasLoader {
    public static void main(String[] args) throws ClassNotFoundException {
        //获取系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //获取系统类加载器的父类加载器---》扩展类加载器
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);

        //获取扩展类加载器的父类——》根加载器（C,C++）无法直接获得 null
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);

        //测试当前类是哪个类加载器加载的
        ClassLoader classLoader = Class.forName("com.annotationAndReflection.TestclasLoader").getClassLoader();
        System.out.println(classLoader);

        //测试JDK内置类：Object类是哪个类加载器加载的
        ClassLoader classLoader1 = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(classLoader1);

        //如何获得系统类加载器可以加载的路径
        System.out.println(System.getProperty("java.class.path"));

        //双亲委派机制，如果你手写了一个已存在的类，会检测是否已经存在，存在则不会用你写的类
        /*
       E:\Environment\Java\JDK\jre\lib\charsets.jar;
       E:\Environment\Java\JDK\jre\lib\deploy.jar;
       E:\Environment\Java\JDK\jre\lib\ext\access-bridge-64.jar;
       E:\Environment\Java\JDK\jre\lib\ext\cldrdata.jar;
       E:\Environment\Java\JDK\jre\lib\ext\dnsns.jar;
       E:\Environment\Java\JDK\jre\lib\ext\jaccess.jar;
       E:\Environment\Java\JDK\jre\lib\ext\jfxrt.jar;
       E:\Environment\Java\JDK\jre\lib\ext\localedata.jar;
       E:\Environment\Java\JDK\jre\lib\ext\nashorn.jar;
       E:\Environment\Java\JDK\jre\lib\ext\sunec.jar;
       E:\Environment\Java\JDK\jre\lib\ext\sunjce_provider.jar;
       E:\Environment\Java\JDK\jre\lib\ext\sunmscapi.jar;
       E:\Environment\Java\JDK\jre\lib\ext\sunpkcs11.jar;
       E:\Environment\Java\JDK\jre\lib\ext\zipfs.jar;
       E:\Environment\Java\JDK\jre\lib\javaws.jar;
       E:\Environment\Java\JDK\jre\lib\jce.jar;
       E:\Environment\Java\JDK\jre\lib\jfr.jar;
       E:\Environment\Java\JDK\jre\lib\jfxswt.jar;
       E:\Environment\Java\JDK\jre\lib\jsse.jar;
       E:\Environment\Java\JDK\jre\lib\management-agent.jar
       ;E:\Environment\Java\JDK\jre\lib\plugin.jar;
       E:\Environment\Java\JDK\jre\lib\resources.jar;
       E:\Environment\Java\JDK\jre\lib\rt.jar;
       E:\learnJava\code\out\production\code;
       E:\learnJava\code\src\lib\commons-io-2.6.jar;
       E:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\lib\idea_rt.jar
        */

    }
}
/*
sun.misc.Launcher$AppClassLoader@18b4aac2
sun.misc.Launcher$ExtClassLoader@74a14482
null
sun.misc.Launcher$AppClassLoader@18b4aac2
null
*/
    